package cn.wolfcode.luowowo.article.service.impl;

import cn.wolfcode.luowowo.article.domain.DestinationThemeTag;
import cn.wolfcode.luowowo.article.mapper.DestinationThemeMapper;
import cn.wolfcode.luowowo.article.mapper.DestinationThemeTagMapper;
import cn.wolfcode.luowowo.article.query.DestinationThemeTagQuery;
import cn.wolfcode.luowowo.article.service.IDestinationThemeTagService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class DestinationThemeTagServiceImpl implements IDestinationThemeTagService {

    @Autowired
    private DestinationThemeMapper destinationThemeMapper;
    @Autowired
    private DestinationThemeTagMapper destinationThemeTagMapper;


    public PageInfo query(DestinationThemeTagQuery qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        return new PageInfo(destinationThemeTagMapper.selectForList(qo));
    }

    public void saveOrUpdate(DestinationThemeTag destinationThemeTag) {
            if (destinationThemeTag!=null){
                destinationThemeTagMapper.updateByPrimaryKey(destinationThemeTag);
            }else {
                destinationThemeTagMapper.insert(destinationThemeTag);
            }
    }

    public List<DestinationThemeTag> queryTagByThemeId(Long themeId) {
        return destinationThemeTagMapper.selectTagByThemeId(themeId);
    }

    public DestinationThemeTag get(Long tagId) {
        return destinationThemeTagMapper.selectByPrimaryKey(tagId);
    }


}